package io.gitee.yxsnake.framework.resource.api;

import com.github.lianjiatech.retrofit.spring.boot.core.RetrofitClient;
import io.gitee.yxsnake.framework.core.domain.Result;
import io.gitee.yxsnake.framework.core.exception.ServiceException;
import io.gitee.yxsnake.framework.resource.api.domain.RemoteFile;
import retrofit2.http.*;

import java.util.List;

/**
 * @author snake
 * @description 文件服务
 * @since 2024/11/3 13:47
 */
@RetrofitClient(baseUrl = "${retrofit.pisces-resource-server:http://pisces-resource-server:21002/}")
public interface RemoteFileService {

    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @POST(value = "inner/file/upload")
    Result<RemoteFile> upload(@Query("name") String name,
                             @Query("originalFilename") String originalFilename,
                             @Query("contentType") String contentType,
                             @Part("file") byte[] file) throws ServiceException;

    /**
     * 通过ossId查询对应的url
     *
     * @param ossIds ossId串逗号分隔
     * @return url串逗号分隔
     */
    @GET ("inner/file/selectUrlByIds")
    Result<String> selectUrlByIds(String ossIds);

    /**
     * 通过ossId查询列表
     * @param ossIds ossId串逗号分隔
     * @return 列表
     */
    @GET ("inner/file/selectByIds")
    Result<List<RemoteFile>> selectByIds(@Query("ossIds") String ossIds);
}

